<%@ page import="util.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%request.setCharacterEncoding("utf-8");
	String url = request.getParameter("url");
	String method = request.getParameter("method");
	String cono = request.getParameter("cono");

	String bname = null;
	String parameterName = null;
	if(request.getParameter("fbname")!=null) {
		bname=request.getParameter("fbname");
		parameterName = "fbname";
	}else if(request.getParameter("dbname")!=null){
		bname=request.getParameter("dbname");
		parameterName = "dbname";
	}else if(request.getParameter("pbname")!=null){
		bname=request.getParameter("pbname");
		parameterName = "pbname";
	}else {
		bname="";
		parameterName = "bname";
	}
	
	
	if(url.indexOf("?")==-1) {
		url = url + "?";
	} else {
		url = url + "&";
	}%>
	
<%Pager pager = (Pager) session.getAttribute("pager");%>
<script type="text/javascript">
<!--
	function getPage(flag){
		var u = "<%=url %>";
		var bn = decodeURIComponent('<%=bname %>');
		u = u + flag;
		u = u + "&cono=<%=cono%>";
		
		u = u + "&<%=parameterName %>="+escape(encodeURIComponent(bn));
		location.href = u;
	}
//-->
</script>
<br>
<table width="100%" border="0" cellspacing="0">
  <tr>
    <td align="center">
    		<%if(pager.getTotalPages()!=0) {%>
    			<a href="javascript:getPage('firstPageGroup=true');">[First]</a>
    		<%}%>
    		
    		<%if(pager.getCurrentPageGroup()>1) {%>
    			<a href="javascript:getPage('previousPageGroup=<%=pager.getCurrentPageGroup()-1%>');">[Previous]</a>
    		<%}%>
    		
    		<%long startPage = pager.getStartPageOfCurrentPageGroup();
				long currentPage = pager.getCurrentPage();
				long pagesPerGroup = pager.getPagesPerGroup();
				long totalPages = pager.getTotalPages();
				System.out.println("currentPage = "+currentPage+" startPage = "+
						startPage+" pagesPerGroup = "+pagesPerGroup+" totalPages = "+totalPages);
				%>
				
  			<%for(long i=startPage; (i<=totalPages && pagesPerGroup!=0); i++) {%>  						
  					<a href="javascript:getPage('currentPage=<%=i%>');">
  					<%if(i==currentPage) {%>[<font color="#54a9ff"><b><%=i%></b></font>]<%} 
  						  else {%>[<%=i%>]<%}%></a> 
  					<%pagesPerGroup--;%>
  		 	<%}%>
    		 
    		<%if(pager.getCurrentPageGroup()<pager.getTotalPageGroups()) {%> 
    				<a href="javascript:getPage('nextPageGroup=<%=pager.getCurrentPageGroup()+1%>');">[Next]</a>    				
    		<%}%>
    		
    		<%if(pager.getTotalPages()!=0) {%>
    				<a href="javascript:getPage('lastPageGroup=true');">[Last]</a>
    		<%}%>
    </td>
  </tr>
</table>